<?php
require_once $GLOBALS['ROO'].'Modules/Geo/class.geo.php';
require_once $GLOBALS['LIB'].'Pr_db/pr_operative.mex';
$GeoCountries = "SELECT pai_CodElite AS ID, pai_NombreESP AS NAME FROM hd_paises ORDER BY NAME ASC";

$Src_Fi = $_GET['CL'];
$Src_Nm = 'CliNumero = ';

if ($Src_Fi > 0) {
    $DetailObj = $GLOBALS['MYT']->db_array($Pr_GetClient . $Src_Nm . $Src_Fi);
} else {
    $MDCL = 'ED';
    $VWCLDT = 1;
    $DetailObj[0] = 1;
    $CLVARS = $MYT->db_array($Pr_DescClient);
    for ($v = 1; $v <= $CLVARS[0]; $v++) {
        $CLVAR = $CLVARS[$v]['Field'];
        $DetailObj[1][$CLVAR] = '';
    }
    $DetailObj[1]['CliProfile'] = 1;
    $DetailObj[1]['CliClass'] = 1;
    $DetailObj[1]['CliOffice'] = $_SESSION[$SESSCD];
    $DetailObj[1]['CliFechaNacimiento'] = '1970-01-01';
    $DetailObj[1]['CliNacionalidad'] = $__sys['Country'];
    $DetailObj[1]['ClPais'] = $__sys['Country'];
}
mn_field('hidden', 'ED', 'CliMap', $DetailObj[1]['CliMap'], '', '', 'False', '');
?>

<table border="0" cellpadding="0" cellspacing="4">
    <tr>
        <td width="105">
<?php mn_field('button', 'ED', 'ob_Description', 'Remetente', '', '', '', 'SUBMIT" style="width:100" onclick="'); ?></td>
        <td><?php
mn_field('text', 'ED', 'CliNumero', $DetailObj[1]['CliNumero'], '10', '10', '', '" readonly=""y onKeyDown="
	  	if((event.keyCode==13 || event.keyCode==9) && this.value > 0) {
			document.pp_frm.action=\'_response/call.php?get=Operative/view/elem_CL.mex\';
			subform(\'pp_frm\',\'FramePanel\');
			}');
echo ' ';
mn_field('select', 'ED', 'CliOffice', $DetailObj[1]['CliOffice'], $Pr_ListOrigensAll, 'Sem origem atribu&iacute;da', '', '');
?></td>
        <td>Notas:</td>
        <td><?php mn_field('text', 'ED', 'ClObs', $DetailObj[1]['ClObs'], '100', '50', '', ''); ?></td>
    </tr>
    <tr>
        <td width="105"><?php
$CliClasses = "Classico;Empresa;Vip#1;2;3";
mn_field('hselect', 'ED', 'CliClass', $DetailObj[1]['CliClass'], $CliClasses, '', 'False', '');
?></td>
        <td><?php mn_field('text', 'ED', 'CliNombre', $DetailObj[1]['CliNombre'], '50', '47', '', ''); ?></td>
        <td>Sexo:</td>
        <td>
            <?php
            $POOLGender = "Masculino;Feminino#M;F";
            $MAPGender = substr($DetailObj[1]['CliMap'], 0, 1);
            mn_field('hselect', 'ED', 'CliGender', $MAPGender, $POOLGender, '', 'False', '');
            echo 'Data Nascimento:';
            mn_field('date', 'ED', 'CliFechaNacimiento', $DetailObj[1]['CliFechaNacimiento'], 'ClientProperties', '8', 'False', '');
            ?></td>
    </tr>
    <tr>
        <td>Morada:</td>
        <td colspan="3">
            <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td><div id="GeoP"><?php $SenderGeo = new Geo(); echo $SenderGeo->GetCountry($Cliente[1]['ClPais'],'ClPais',null,$Cliente[1]['CliProvincia'],'','ED'); ?></div></td>
                    <td><div id="GeoR"><?php echo $SenderGeo->GetRegion($Cliente[1]['CliProvincia'],'CliProvincia',$Cliente[1]['ClPais'],'ClientProperties','ED'); ?></div></td>
                    <td><div id="GeoCC"><?php echo $SenderGeo->GetCity($Cliente[1]['CliCiudad'], 'CliCiudad', $Cliente[1]['CliProvincia'], $Cliente[1]['ClPais'], 'ClientProperties', 'ED'); ?></div></td>
                </tr>
            </table></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><?php mn_field('text', 'ED', 'CliDomicilio', $DetailObj[1]['CliDomicilio'], '30', '47', '', ''); ?></td>
        <td>Actividade:</td>
        <td><?php mn_field('text', 'ED', 'CliActividad', $DetailObj[1]['CliActividad'], '30', '50', '', ''); ?></td>
    </tr>
    <tr>
        <td>Andar</td>
        <td><?php
            mn_field('text', 'ED', 'CliPortal', $DetailObj[1]['CliPortal'], '3', '1', '', '');
            echo ' ';
            mn_field('text', 'ED', 'CliPisoPuerta', $DetailObj[1]['CliPisoPuerta'], '5', '3', '', '');
            echo ' Loc.';
            mn_field('text', 'ED', 'CliLocation', $DetailObj[1]['CliLocation'], '15', '10', '', '');
            echo ' CP';
            mn_field('text', 'ED', 'CliCP', $DetailObj[1]['CliCP'], '8', '4', '', '');
            ?></td>
        <td>Naturalidade:</td>
        <td><?php
            $Qur = "SELECT pai_CodElite AS ID, pai_NombreUSD AS NAME FROM hd_paises";
            mn_field('select', 'ED', 'CliNacionalidad', $DetailObj[1]['CliNacionalidad'], $Qur, '', '', ''); ?></td>
    </tr>
    <tr>
        <td>Nacionalidade</td>
        <td colspan="3"><?php mn_field('select', 'ED', 'CliRes1', $DetailObj[1]['CliRes1'], $GeoCountries, ' ', 'False', ''); ?>&nbsp;Nacionalidade Outra:
<?php mn_field('select', 'ED', 'CliRes2', $DetailObj[1]['CliRes2'], $GeoCountries, ' ', 'False', ''); ?></td>
    </tr>
    <tr>

        <td>Telefone:</td>
        <td colspan="3"><?php
            mn_field('text', 'ED', 'CliTelefono', $DetailObj[1]['CliTelefono'], '16', '16', '', '');
            echo ' Telemovel: ';
            mn_field('text', 'ED', 'CliTelefono2', $DetailObj[1]['CliTelefono2'], '16', '16', '', '');
            echo ' Email: ';
            mn_field('text', 'ED', 'CLCttEmail', $DetailObj[1]['CLCttEmail'], '40', '40', '', '');
            echo ' Disp: ';
            $Qur = "Contactavel;Incontactavel#0;1";
            mn_field('hselect', 'ED', 'CliMailing', 0, $Qur, '', '', '');
?></td>
    </tr>
</table>